<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.text.SimpleDateFormat,java.text.DateFormat,java.util.Date"%>
<%@ include file="/WEB-INF/common/taglib.jsp" %>
<%
	Date now = new Date();
	DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	String nowStr = df.format(now);
%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>渠道管理</title>
   	<link rel="stylesheet" href="${ctx}/static/css/Master.css"/>
	<link rel="stylesheet" href="${ctx}/static/css/lq.datetimepick.css"/>
	<script src="${ctx}/static/js/jquery-1.9.0.min.js"></script>
	<script src="${ctx}/static/js/simpletooltip.min.js"></script>
	<script type="text/javascript" src="${ctx}/static/js/jsScroller.js"></script>
	<script type="text/javascript" src="${ctx}/static/js/jsScrollbar.js"></script>
	<script src="${ctx}/static/js/selectUi.js"></script>
	<script src="${ctx}/static/js/orgCommon.js"></script>
	<script src="${ctx}/static/js/layer.js"></script>
	<script src="${ctx}/static/js/common/util.js"></script>
	<script type="text/javascript">
	function fn(li)
	{
		$("#auditStatus").val(li);
		$("#currentPage").val(1);
		searchOrg();
	}
	function searchOrg(){
		$("#trenchForm").submit();
	}
	function isDisabled(orgId,orgName,normal)
	{
		var msg = '确认'+(normal==1?'禁用':'启用')+'"'+orgName+'"吗?';
		top.layer.confirm(msg, {icon: 3}, function(index){
			$.ajax({    
			    url:"${ctx}/organization/updateByAuditStatus",   
			    data:{"orgId":orgId,"normal":(normal==1?0:1)},    
			    type:"post",    
			    cache:false,    
			    dataType:"json",
			    async:true, //默认为true 异步    
			    success:function(data) {
		            top.layer.msg("操作成功!!",{},function(){
			        	window.location.reload();   
		            });
			     },    
			     error : function(XMLHttpRequest, textStatus, errorThrown) {
			         top.layer.alert(XMLHttpRequest.responseText);
		  		 }   
			});
		});
	}
	</script>
	<style type="text/css">
		.SearchList li span
		{
		  float: initial;
		}
		.SearchList li input {
		  border: 1px solid #dfdfdf;
		  height: 30px;
		  line-height: 16px;
		  padding: 5px;
		  width: 148px;
		  margin-right: 10px;
		}
		.selectul
		{
		  position: relative;
		  display: inline-block;
		  cursor: pointer;
		  float: initial;
		  margin-right: 10px;
		}
		.wrapper input{
		  height: 30px !important
		}
	</style>
  </head>
  
  <body>

<div class="wrapper">
	<form id="trenchForm" action="${ctx }/organization/trenchlist" method="get">
	<section >
		<section>
			<section class="boxRight">
				<div class="context boxborder">
					<div class="SearchList">
						<ul class="clearfix">
							<input type="hidden" id="auditStatus" name="auditStatus" value="${result.entity.auditStatus }" />
							<li><span class="name">渠道名称：</span><span class="pt"><input id="orgName" name="orgName" type="text" value="${result.entity.orgName }" /></span></li>
							<li><span class="name">组织归属： </span>
								<select id="orgPIdList" name="orgPId" class="selectul selectul_w1 organization" dir="${result.entity.orgPId }">
									<option value="0">请选择</option>
								</select>
							</li>
							<li><span class="name">状态：</span><span class="pt">
								<select name="normal" id="normal">
								<option value="-1" >请选择</option>
						     	<c:forEach items="${diy:getDicList('NORMAL')}" var="dic">
						     	<option value="${dic.code}" <c:if test="${dic.code == result.entity.normal}">selected="selected"</c:if>>${dic.content}</option>
						     	</c:forEach>
						    	</select>
						     </span></li>
							<li class="combtn pr"><a href="javascript:searchOrg(0);">查询</a></li>
						</ul>
					</div>
					<div class="pr prlink"><a href="${ctx}/organization/addTrench" ><span class="icon j_icon"></span>新增渠道商</a></div>
					<div class="tabnavList">
						<ul id="clearfix" class="clearfix">
							<li onclick="fn();" <c:if test="${result.entity.auditStatus == null}">class="curr"</c:if>>全部</li>
							<li onclick="fn(0);" <c:if test="${result.entity.auditStatus == 0}">class="curr"</c:if>>草稿箱</li>
							<li onclick="fn(1);" <c:if test="${result.entity.auditStatus == 1}">class="curr"</c:if>>待审核</li>
							<li onclick="fn(2);" <c:if test="${result.entity.auditStatus == 2}">class="curr"</c:if>>已审核</li>
						</ul>
					</div>
					<div class="com_table">
						<table width="100%" cellpadding="0" cellspacing="0">
							<tr>
								<th>序号</th>
								<th>渠道名称</th>
								<th>所属平台</th>
								<th>所在地</th>
								<th>负责人</th>
								<th>负责人电话</th>
								<th>开发社区数</th>
								<th>审批状态</th>
								<th>状态</th>
								<th>创建时间</th>
								<th>操作</th>
							</tr>
							<c:forEach var="org" items="${result.entityList }" varStatus="orgs">
							<tr>
								<td>${orgs.index + 1 }</td>
								<td>${org.orgName }</td>
								<td>${org.platformName }</td>
								<td>${org.provinceName }${org.cityName }${org.areaName }</td>
								<td>${org.contactName }</td>
								<td>${org.contactNumber }</td>
								<td>${org.comCount }</td>
								<td>${org.auditContent }</td>
								<td>${org.content }</td>
								<td>
								<div class="utilTips">
								<pretty:prettyTime date="${org.insertDate}"/>
								<div class="utilTipsText" style="display: none;"><fmt:formatDate value="${org.insertDate}" pattern="yyyy-MM-dd" /></div>
								</div>
								</td>
								<td class="left"><a class="icon micon_9" title="详情" href="${ctx }/organization/trenchByIdDetails.do?orgId=${org.orgId}"></a><a class="icon micon_${org.normal == 1? 1 : 12}" title="${org.normal == 1? '停用' : '启用'}" href="javascript:isDisabled('${org.orgId}','${org.orgName}','${org.normal}');"></a><a class="icon micon_10" <c:if test="${org.auditStatus != 2 }">style="display: none;"</c:if> title="生成帐号" href="${ctx }/organization/${org.orgId}/userCreate.do"></a><a class="icon micon_11" title="更新资料" href="${ctx }/organization/selectTrenchById.do?orgId=${org.orgId}"></a></td>
							</tr>
							</c:forEach>
						</table>
						<%-- 分页 --%>
						<%@ include file="/WEB-INF/common/page.jsp"%>
					</div>
				</div>
			
		</section>
		</section>
	<!--/左边-->
	</section>
	</form>
</div>

  </body>
</html>
